package config

import (
	"fmt"
	"os"

	"github.com/getlantern/systray"
	"github.com/pelletier/go-toml/v2"
	"keyHook/mylogo"
)

var Isdebug bool

// InitConfig 配置初始化
func InitConfig() {
	file, err := os.ReadFile("map.toml")
	err = toml.Unmarshal(file, &Cfg)
	if err != nil {
		fmt.Println("读取配置错误!", err.Error())
		return
	}
	//fmt.Println(Cfg)
}

// OnReady 状态栏初始化
func OnReady() {
	systray.SetIcon(mylogo.Logo)
	systray.SetTitle("键盘音程序")
	systray.SetTooltip("退出")
	mHome := systray.AddMenuItem("开启/关闭 Debug", "开启/关闭 调试模式")
	go func() {
		<-mHome.ClickedCh
		Isdebug = !Isdebug
	}()
	mQuit := systray.AddMenuItem("Quit", "Quit app")
	go func() {
		<-mQuit.ClickedCh
		systray.Quit()
	}()
}
